package com.maiji.cloud.controller.shopingmall;

import com.maiji.cloud.controller.BaseController;
import com.maiji.cloud.request.BaseDataReqDto;
import com.maiji.cloud.request.shopingmall.*;
import com.maiji.cloud.response.BaseDataResDto;
import com.maiji.cloud.response.BaseMetaResDto;
import com.maiji.cloud.response.BaseResDto;
import com.maiji.cloud.response.shopingmall.GoodsParamConfigResData;
import com.maiji.cloud.response.shopingmall.GoodsResData;
import com.maiji.cloud.response.shopingmall.ParamConfigResData;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;
import java.util.List;

@RestController
@RequestMapping("/goods/")
@Api(tags = {"商品模块"})
public class GoodsController extends BaseController {

    /**
     *  添加商品
     * @param baseDataReqDto
     * @return
     */
    @ApiOperation(value = "添加商品")
    @PostMapping("addGoods")
    public BaseResDto addGoods (@RequestBody BaseDataReqDto<GoodsReqData> baseDataReqDto) {
        return restTemplate.postForObject(REST_URL_SHOPINGMALL + "/goods/addGoods", baseDataReqDto, BaseResDto.class);
    }

    /**
     *  编辑商品
     * @param baseDataReqDto
     * @return
     */
    @ApiOperation(value = "编辑商品")
    @PostMapping("updateGoods")
    public BaseResDto updateGoods (@RequestBody BaseDataReqDto<GoodsReqData> baseDataReqDto) {
        return restTemplate.postForObject(REST_URL_SHOPINGMALL + "/goods/updateGoods", baseDataReqDto, BaseResDto.class);
    }

    /**
     *  编辑商品的标签
     * @param baseDataReqDto
     * @return
     */
    @ApiOperation(value = "编辑商品的标签")
    @PostMapping("updateGoodsLabels")
    public BaseResDto updateGoodsLabels (@RequestBody BaseDataReqDto<LabelBelongUpdateReqData> baseDataReqDto) {
        return restTemplate.postForObject(REST_URL_SHOPINGMALL + "/goods/updateGoodsLabels", baseDataReqDto, BaseResDto.class);
    }

    /**
     *  编辑商品的图片
     * @param baseDataReqDto
     * @return
     */
    @ApiOperation(value = "编辑商品的图片")
    @PostMapping("updateGoodsImages")
    public BaseResDto updateGoodsImages (@RequestBody BaseDataReqDto<GoodsImagesUpdateReqData> baseDataReqDto) {
        return restTemplate.postForObject(REST_URL_SHOPINGMALL + "/goods/updateGoodsImages", baseDataReqDto, BaseResDto.class);
    }

    /**
     *  获取商品的标签
     * @param baseDataReqDto
     * @return
     */
    @ApiOperation(value = "获取商品的标签")
    @PostMapping("findAllLabelsByGoodsId")
    public BaseDataResDto<List<String>> findAllLabelsByGoodsId (@RequestBody BaseDataReqDto<String> baseDataReqDto) {
        return restTemplate.postForObject(REST_URL_SHOPINGMALL + "/goods/findAllLabelsByGoodsId", baseDataReqDto, BaseDataResDto.class);
    }

    /**
     *  根据商品ID查看商品详情
     * @param baseDataReqDto
     * @return
     */
    @ApiOperation(value = "查看商品详情")
    @PostMapping("findGoodsById")
    public BaseDataResDto<GoodsResData> findGoodsById (@RequestBody BaseDataReqDto<String> baseDataReqDto) {
        return restTemplate.postForObject(REST_URL_SHOPINGMALL + "/goods/findGoodsById", baseDataReqDto, BaseDataResDto.class);
    }

    /**
     *  查询商品列表
     * @return
     */
    @PostMapping("findAllGoods")
    @ApiOperation(value = "查询商品列表")
    public BaseMetaResDto<List<GoodsResData>> findAllGoods(@RequestBody BaseDataReqDto<GoodsFindAllReqData> baseDataReqDto) {
    	return restTemplate.postForObject(REST_URL_SHOPINGMALL + "/goods/findAllGoods", baseDataReqDto, BaseMetaResDto.class);
    }

    /**
     *  根据标签ID[]查询商品列表
     * @param baseDataReqDto
     * @return
     */
    @PostMapping("findAllGoodsByLabelIds")
    @ApiOperation(value = "根据标签ID[]查询商品列表")
    public BaseMetaResDto<GoodsResData> findAllGoodsByLabelIds(@RequestBody BaseDataReqDto<List<String>> baseDataReqDto) {
    	return postForObjectWithToken(null, REST_URL_SHOPINGMALL + "/goods/findAllGoodsByLabelIds", baseDataReqDto, BaseMetaResDto.class);
    }

    /**
     *  查询可积分兑换的商品列表
     * @param baseReqMetaDto
     * @return
     */
    @PostMapping("findAllExchangeGoods")
    @ApiOperation(value = "查询可积分兑换的商品列表")
    public BaseMetaResDto<List<GoodsResData>> findAllExchangeGoodsPC(@RequestBody BaseDataReqDto<String> baseReqMetaDto) {
    	return restTemplate.postForObject(REST_URL_SHOPINGMALL + "/goods/findAllExchangeGoodsPC", baseReqMetaDto, BaseMetaResDto.class);
    }

    /**
     *  获取精选热卖商品列表
     * @return
     */
    @PostMapping("findAllRecommendGoods")
    @ApiOperation(value = "获取精选热卖商品列表")
    public BaseMetaResDto<List<GoodsResData>> findAllRecommendGoods(@RequestBody BaseDataReqDto<String> baseReqMetaDto) {
        return restTemplate.postForObject(REST_URL_SHOPINGMALL + "/goods/findAllRecommendGoods", baseReqMetaDto, BaseMetaResDto.class);
    }

    /**
     *  获取新品推荐商品列表
     * @return
     */
    @PostMapping("findAllNewGoods")
    @ApiOperation(value = "获取新品推荐商品列表")
    public BaseMetaResDto<List<GoodsResData>> findAllNewGoods(@RequestBody BaseDataReqDto<String> baseReqMetaDto) {
        return restTemplate.postForObject(REST_URL_SHOPINGMALL + "/goods/findAllNewGoods", baseReqMetaDto, BaseMetaResDto.class);
    }

    /**
     *  获取特惠专区商品列表
     * @return
     */
    @PostMapping("findAllPreferentialGoods")
    @ApiOperation(value = "获取特惠专区商品列表")
    public BaseMetaResDto<List<GoodsResData>> findAllPreferentialGoods(@RequestBody BaseDataReqDto<String> baseReqMetaDto) {
        return restTemplate.postForObject(REST_URL_SHOPINGMALL + "/goods/findAllPreferentialGoods", baseReqMetaDto, BaseMetaResDto.class);
    }

    /**
     *  快捷添加/取消商品标签
     * @return
     */
    @PostMapping("editLabelMidGoods")
    @ApiOperation(value = "快捷添加/取消商品标签")
    public BaseResDto editLabelMidGoods(@RequestBody BaseDataReqDto<GoodsReqData> baseReqMetaDto) {
        return restTemplate.postForObject(REST_URL_SHOPINGMALL + "/goods/editLabelMidGoods", baseReqMetaDto, BaseMetaResDto.class);
    }

    /**
     *  统计需要及时增加库存的商品数量
     * @return
     */
    @PostMapping("IncreasestockVolumeCount")
    @ApiOperation(value = "统计需要及时增加库存的商品数量")
    public BaseDataResDto<Integer> IncreasestockVolumeCount(@RequestBody BaseDataReqDto<Integer> baseReqMetaDto) {
        return restTemplate.postForObject(REST_URL_SHOPINGMALL + "/goods/IncreasestockVolumeCount", baseReqMetaDto, BaseDataResDto.class);
    }

    /**
     *  根据商品id获得产品参数列表-平台
     * @return
     */
    @PostMapping("getParamConfigByGoodsId")
    @ApiOperation(value = "根据商品id获得产品参数列表-平台")
    public BaseDataResDto<List<ParamConfigResData>> getParamConfigByGoodsId(@RequestBody BaseDataReqDto<String> baseReqMetaDto) {
        return restTemplate.postForObject(REST_URL_SHOPINGMALL + "/goods/getParamConfigByGoodsId", baseReqMetaDto, BaseDataResDto.class);
    }

    /**
     *  编辑商品参数类型
     * @return
     */
    @PostMapping("editParamConfigs")
    @ApiOperation(value = "编辑商品参数类型")
    public BaseDataResDto<List<ParamConfigResData>> editParamConfigs(@RequestBody BaseDataReqDto<List<ParamConfigReqData>> baseReqMetaDto) {
        return restTemplate.postForObject(REST_URL_SHOPINGMALL + "/goods/editParamConfigs", baseReqMetaDto, BaseDataResDto.class);
    }

    /**
     *  编辑商品参数类型
     * @return
     */
    @PostMapping("delParamConfigs")
    @ApiOperation(value = "删除商品参数类型")
    public BaseResDto delParamConfigs(@RequestBody BaseDataReqDto<String> baseReqMetaDto) {
        return restTemplate.postForObject(REST_URL_SHOPINGMALL + "/goods/delParamConfigs", baseReqMetaDto, BaseResDto.class);
    }

}
